package com.zhang.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.zhang.mapper.IRoleMapper;
import com.zhang.pojo.RoleBean;
import com.zhang.service.IRoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@Transactional
public class RoleServiceImpl implements IRoleService {
    @Autowired
    private IRoleMapper roleMapper;

    @Override
    public List<RoleBean> findAll() {
        return roleMapper.findAll();
    }

    @Override
    public IPage<RoleBean> findByPage(Page<RoleBean> page) {
        return roleMapper.findByPage(page);
    }

    @Override
    public void add(RoleBean role,int[] powerIds) {
        roleMapper.add(role);
        roleMapper.addPower(role.getId(),powerIds);
    }

    @Override
    public void del(int roleId) {
        roleMapper.del(roleId);
    }

    @Override
    public RoleBean findById(int roleId) {
       return roleMapper.findById(roleId);
    }

    @Override
    public void update(int roleId,int[] powerIds) {
        roleMapper.update(roleId,powerIds);
    }
}
